﻿@page "/Base_Manage/Base_Test/List"

@inherits BaseListWithEdit<Base_TestDTO, EditForm>

<Space Size="@("small")">

    @if (Operator.HasPerm("Base_Test.Add"))
    {
        <SpaceItem>
            <Button Type="@ButtonType.Primary" Icon="plus" OnClick="()=>Edit()">新建</Button>
        </SpaceItem>
    }
    @if (Operator.HasPerm("Base_Test.Delete"))
    {
        <SpaceItem>
            <Popconfirm Title="确认删除选中项吗?"
                    OnConfirm="()=>Delete()"
                    OnCancel="()=>{}"
                    OkText="确定"
                    CancelText="取消"
                    Disabled=@NoneSelectedItems>
                <Button Type="@ButtonType.Primary" Danger Icon="minus" Disabled=@NoneSelectedItems>删除</Button>
            </Popconfirm>
        </SpaceItem>
    }
    <SpaceItem>
        <SimpleSelect DefaultActiveFirstOption @bind-Value="@Condition">
            <SelectOptions>
                <SimpleSelectOption Value="TenantId" Label="TenantId"></SimpleSelectOption>
                <SimpleSelectOption Value="ParentId" Label="ParentId"></SimpleSelectOption>
                <SimpleSelectOption Value="Name" Label="Name"></SimpleSelectOption>
                <SimpleSelectOption Value="Url" Label="Url"></SimpleSelectOption>
                <SimpleSelectOption Value="Value" Label="Value"></SimpleSelectOption>
                <SimpleSelectOption Value="Icon" Label="Icon"></SimpleSelectOption>
                <SimpleSelectOption Value="ModifyId" Label="ModifyId"></SimpleSelectOption>
                <SimpleSelectOption Value="ModifyName" Label="ModifyName"></SimpleSelectOption>
            </SelectOptions>
        </SimpleSelect>
    </SpaceItem>
    <SpaceItem>
        <Search Placeholder="关键字" EnterButton="true" @bind-Value="@KeyWord" OnSearch="()=>Refresh()" />
    </SpaceItem>
</Space>

<Table @ref="_table" 
       TItem="Base_TestDTO" 
       DataSource="Data"  
       EnableVirtualization
       Loading="Loading" 
       @bind-PageSize="Pagination.PageRows" 
       @bind-SelectedRows="SelectedItems"
       ScrollX="1800"
       ScrollBarWidth="12px"
       Size="TableSize.Small"
       RowClassName="@(x => x.RowIndex % 2 == 0 ?"gray-2":"")">
    <ChildContent>
        <Selection Key="@(context.Id)" />
        <AntDesign.Column Title="TenantId" DataIndex="TenantId" TData="System.String"/>
        <AntDesign.Column Title="ParentId" DataIndex="ParentId" TData="System.String"/>
        <AntDesign.Column Title="Type" DataIndex="Type" TData="System.Int32"/>
        <AntDesign.Column Title="Name" DataIndex="Name" TData="System.String"/>
        <AntDesign.Column Title="Url" DataIndex="Url" TData="System.String"/>
        <AntDesign.Column Title="Value" DataIndex="Value" TData="System.String"/>
        <AntDesign.Column Title="NeedTest" DataIndex="NeedTest" TData="System.Boolean"/>
        <AntDesign.Column Title="Icon" DataIndex="Icon" TData="System.String"/>
        <AntDesign.Column Title="Sort" DataIndex="Sort" TData="System.Int32"/>
        <AntDesign.Column Title="ModifyTime" DataIndex="ModifyTime" TData="System.DateTime"/>
        <AntDesign.Column Title="ModifyId" DataIndex="ModifyId" TData="System.String"/>
        <AntDesign.Column Title="ModifyName" DataIndex="ModifyName" TData="System.String"/>
       
        <ActionColumn Title="Action" Fixed="right">
            <Space Size=@("small")>
                <SpaceItem>
                    <Button Type="@ButtonType.Link" Style="padding:0px" OnClick="()=>Edit(context)">Edit</Button>
                    <Popconfirm Title="确认删除吗?"
                                OnConfirm="()=>Delete(context.Id)"
                                OnCancel="()=>{}"
                                OkText="确定"
                                CancelText="取消">
                        <Button Danger Type="@ButtonType.Link" Style="padding:0px">Delete</Button>
                    </Popconfirm>
                </SpaceItem>
            </Space>
        </ActionColumn>
    </ChildContent>
    <PaginationTemplate>
        <div style="float:right;margin-top:10px">
            <Pagination Total="Pagination.Total"
                        ShowTotal="ShowTotal"
                        ShowSizeChanger
                        PageSize="Pagination.PageRows"
                        Current="Pagination.PageIndex"
                        OnChange="PageIndexChanged"
                        OnShowSizeChange="PageSizeChanged" />
        </div>
    </PaginationTemplate>
</Table>

<style>
    .gray-2 {
        background-color: #fafafa;
    }
</style>

@code
{
    public List()
    {
        Area = "Base_Manage";
        //Condition = "Name";
    }

     protected override string GetDataJson()
    {        
        return base.GetDataJson();
    }

    protected override async Task GetData()
    {
        await base.GetData();
    }

    protected override void Edit(Base_TestDTO para = null)
    {
        base.Edit(para);
    }

    protected override async Task Delete(List<string> ids)
    {
        await base.Delete(ids);
    }
}